from abc import ABC, abstractmethod
from pathlib import Path


class ContentExtractor(ABC):
    """内容提取器抽象基类"""

    @abstractmethod
    def extract(self, file_path: str) -> str:
        """从文件中提取文本内容"""
        pass


class UnsupportedFormatError(Exception):
    """不支持的文件格式异常"""

    def __init__(self, file_extension: str):
        super().__init__(f"Unsupported file format: {file_extension}")
        self.file_extension = file_extension


class FileReadError(Exception):
    """文件读取异常"""

    def __init__(self, file_path: str, detail: str):
        super().__init__(f"Failed to read file {file_path}: {detail}")
        self.file_path = file_path
        self.detail = detail